﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace DirectX_CS
{
	class Buoy
	{
		Cartesian3dAxis axisOnBody;
		EquilibriumPoint mParticle = null;

		private float poleHeight = 100f;
		private bool allowChangeCamera = false;
		[PGBrowsable]
		private bool AllowChangeCamera
		{
			get { return allowChangeCamera; }
			set { allowChangeCamera = value; }
		}
		[PGBrowsable]
		public float PoleHeight
		{
			get { return poleHeight; }
			set { poleHeight = value; }
		}
		float maxZ = 0;
		public float MaxZ
		{
			get { return maxZ; }
			set { maxZ = value; }
		}
		public EquilibriumPoint AssociatedParticle
		{
			get { return mParticle; }
			set { 
				mParticle = value;
				if (mParticle != null)
				{

					Vector3 pos = value.Position;
					axisOnBody.ModelView.Position = pos;
					axisOnBody.Recreate();

					if (allowChangeCamera)
					{
						Camera.DefaultCamera.CameraPosition = new Vector3(pos.X, pos.Y, pos.Z + poleHeight + maxZ); //10 for pole 
						Camera.DefaultCamera.SetViewTransform();
					}
				}
			}
		}

		public Buoy(Device dxDevice, PrimitiveManager managedRenderer)
		{
			axisOnBody = new Cartesian3dAxis(0f, 7.5f, 0f, 2.5f, 0f, poleHeight, 10, 10, 10);
			float largeNumber = 1000000f;
			if (allowChangeCamera)
			{
				Vector3 cameraTarget = Camera.DefaultCamera.CameraTarget = new Vector3(largeNumber, largeNumber, maxZ);
			}

		}
	
	}
}
